from PIL import Image
import os

path = os.getcwd()

for file in os.listdir(path):
    print(file)
    image_format = file.split('.')[-1]
    if image_format == 'png' or image_format == 'jpg':
        img = Image.open(file)
        if img.mode in ('RGBA', 'LA'):
            img = img.convert('RGB')
            name = file.split('.')[0]
            img.save(name + '.eps', 'EPS')
        else:
            name = file.split('.')[0]
            img.save(name + '.eps', 'EPS')
    else:
    	print('not an image!')